package com.yjz.media.study.rtmp;


/**
 * 作用 : RTMP Native操作类
 * 作者 : yjz
 * 时间 : 2023/11/7 17:25
 */
public class RTMPNativeHelper {

    static {
        System.loadLibrary("study");
    }

    public static volatile RTMPNativeHelper rtmpNativeHelper;

    public static RTMPNativeHelper getInstance() {
        if (rtmpNativeHelper == null) {
            synchronized (RTMPNativeHelper.class) {
                if (rtmpNativeHelper == null) {
                    rtmpNativeHelper = new RTMPNativeHelper();
                }
            }
        }
        return rtmpNativeHelper;
    }

    /**
     * 连接rtmp
     *
     * @param url 连接的url
     * @return 是否连接成功
     */
    public native boolean connectRTMP(String url);

    /**
     * 发送数据包
     *
     * @param buffer 数据
     * @param type   类型
     */
    public native void sendData(byte[] buffer, int length, int type);

    /**
     * 断开连接
     */
    public native void disconnect();
}
